!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01102fc8-be00-4ec8-99c2-1e4d2bbfccb6",e._sentryDebugIdIdentifier="sentry-dbid-01102fc8-be00-4ec8-99c2-1e4d2bbfccb6")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9284],{64979:function(e,t,r){r.d(t,{$m:function(){return R},C0:function(){return y},EQ:function(){return d},F4:function(){return N},H$:function(){return v},IS:function(){return x},Iu:function(){return s},Kq:function(){return f},Nc:function(){return k},OI:function(){return c},PF:function(){return n},RJ:function(){return z},S3:function(){return l},Vj:function(){return g},W$:function(){return I},YT:function(){return u},Zq:function(){return C},Zv:function(){return b},_R:function(){return E},cm:function(){return o},e5:function(){return _},f3:function(){return w},os:function(){return a},p3:function(){return i},u4:function(){return h},vl:function(){return O},wK:function(){return m},wj:function(){return D},wy:function(){return p},xQ:function(){return T}}),r(12976).p;let o="download_after_removing_bg",n="copy_after_removing_bg",i="edit_after_removing_bg",a="ai_tool_removebg",l="ai_tool_expand",u="ai_tool_expand_after_download",c="ai_tool_expand_carousel",s="ai_tool_expand_removebg",_="ai_tool_expand_download_popover",d="ai_tool_retouch",f="ai_tool_retouch_download_popover",p="ai_tool_retouch_after_download",g="ai_tool_reimagine",m="ai_tool_reimagine_download_popover",w="ai_tool_reimagine_after_download",v="ai_tool_upscaler",b="ai_tool_replacebg",y="ai_tool_all",h="ai_tool_all_thumbnail",k="ai_tool_adjust",I="ai_tool_video",x="ai_tool_generate_style_ref",N="ai_tool_generate_prompt",R="ai_tool_assistant",z="edit_tools_onboarding_v2",O="edit_tools_onboarding",T=["replacebg","video","generatePrompt","styleReference"],C=["tint","grain","presets"],E=2e3,D=15},42997:function(e,t,r){r.d(t,{i:function(){return d}});var o=r(41937),n=r(65122),i=r(20176),a=r(90312),l=r(85229),u=r(52983),c=r(65724),s=r(64979),_=r(35845);let d=e=>{let{tool:t,subOption:r,resourceData:s,checkoutQueryParams:d}=e,p=(0,o.I)(),g=(0,_.e)(t),m=(0,n.e)(),{setLoginCookies:w,signUpUrl:v}=(0,a.e)(),b=(0,c.W)(s.id),y=(null==s?void 0:s.premium)||!1,h=m||!y,{isUserWinback:k,showWinbackModal:I}=(0,l.l)(),{showDeviceBlockedModal:x,isDeviceBlocked:N}=(0,i.q)();return(0,u.useCallback)(()=>N?(x(),!0):k?(I(),!0):(!h||!g)&&(p&&h&&!f(t,r)?(w(),window.location.href=v):b({resourceData:{name:null==s?void 0:s.name,mediaUrl:s.preview.url,mediaWidth:s.preview.width,mediaHeight:s.preview.height,resourceType:"regular"},checkoutQueryParams:d}),!0),[N,k,h,g,p,t,r,b,null==s?void 0:s.name,s.preview.url,s.preview.width,s.preview.height,d,x,I,w,v])},f=(e,t)=>s.xQ.includes(e)||t&&s.Zq.includes(t)},35845:function(e,t,r){r.d(t,{C:function(){return _},e:function(){return c}});var o=r(11645),n=r(41937),i=r(2394),a=r(18444),l=r(8147),u=r(52983);let c=e=>_()(e),s={removebg:"freepik-tools-integration-remove-bg",retouch:"pikaso-edition",expand:"pikaso-edition",reimagine:"pikaso-reimagine",replacebg:"pikaso-bg-replacer",video:"pikaso-video-kling",generatePrompt:"pikaso-tti",styleReference:"pikaso-tti",assistant:"pikaso-edition"},_=()=>{let e=(0,l.H)(),t=(0,n.I)(),r=(0,a.w)(),c=(0,i.E)(),_=(0,o.u)(),d=null==e?void 0:e.permissions;return(0,u.useCallback)(e=>{let o=s[e];if(c)return!o||_(o);if(!d)return!1;let{canUseIA:n}=d,i=n&&!t,a=i&&!r;return({replacebg:i&&a,retouch:i,removebg:i,expand:i,reimagine:i,adjust:!t,video:i&&a,generatePrompt:i&&a,styleReference:i&&a,assistant:i,workflow:i})[e]},[c,d,t,r,_])}},33843:function(e,t,r){r.d(t,{BP:function(){return s},Us:function(){return n},Zq:function(){return u},bE:function(){return a},yS:function(){return d}});let o=["pixel-art","illustration","surreal","comic","fantasy","anime","digital-art","vintage","photo","all-styles"],n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return o.includes(e)},i=["1:1","1:2","2:1","2:3","3:4","4:5","9:16","3:2","4:3","16:9","custom"],a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return i.includes(e)},l=["crop","light","color","tint","grain","rotate","presets"],u=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return l.includes(e)},c=["createSocialPost","createPoster","createFlyer","mixImages","applyPromo"],s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return c.includes(e)},_=["remove","insert"],d=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return _.includes(e)}},94608:function(e,t,r){r.d(t,{W:function(){return a}});var o=r(33843);let n={video:"ai_video_generator",adjust:"adjust",reimagine:"reimagine",expand:"expand",removebg:"background",retouch:"retouch",replacebg:"background",generatePrompt:"ai_image_generator",styleReference:"ai_image_generator",assistant:"assistant",workflow:"assistant"},i=(e,t)=>{if("removebg"===e)return"remove";if("replacebg"===e)return"replace";if("reimagine"===e&&(0,o.Us)(t))return"all-styles"===t?"style":"style__".concat(t);if("expand"===e&&(0,o.bE)(t))return"aspect_ratio__".concat(t);if("adjust"===e&&(0,o.Zq)(t)||"retouch"===e&&(0,o.yS)(t))return t;if("generatePrompt"===e)return"prompt__image_reference";if("styleReference"===e)return"style__image_reference";if("workflow"===e&&(0,o.BP)(t)){if("createSocialPost"===t)return"workflow__create_post";if("createPoster"===t)return"workflow__create_poster";if("createFlyer"===t)return"workflow__create_flyer";if("mixImages"===t)return"workflow__mix_images";if("applyPromo"===t)return"workflow__apply_promo";throw Error("Invalid subOption: ".concat(t))}return"ai_gen"},a=(e,t)=>({tool:n[e],eventName:i(e,t),businessLine:"ai_tools,content"})},52753:function(e,t,r){r.d(t,{d:function(){return o}});let o=(e,t,r)=>"resource_detail".concat(e?"":"_free","_").concat(null!=t?t:"ai_tools").concat(r?"_".concat(r):"")},15715:function(e,t,r){r.d(t,{H:function(){return n}});let o=e=>{let{resource:t,file:r,option:o,size:n,action:i,walletId:a,locale:l,modifier:u}=e,c=new URLSearchParams;return c.set("resource","".concat(t)),r&&o?(c.set("file",r),c.set("option","".concat(o))):n&&c.set("size","".concat(n)),i&&c.set("action",i),a&&c.set("walletId",a),c.set("locale",l),u&&c.set("modifier",u),c.toString()},n=async e=>{let t=o(e),r=await fetch("/api/regular/download?".concat(t));return r.ok?{success:!0,data:await r.json()}:429===r.status?{success:!1,data:"DOWNLOAD_LIMIT_REACHED",metadata:"/download-limit"}:401===r.status||403===r.status||405===r.status?{success:!1,data:"AUTHENTICATION_ERROR"}:404===r.status?{success:!1,data:"NOT_FOUND"}:{success:!1,data:"UNKNOWN_ERROR"}}},75045:function(e,t,r){r.d(t,{i:function(){return E}});var o=r(59445),n=r(15880),i=r(68147),a=r(85229),l=r(87420),u=r(59608),c=r(52983),s=r(66454),_=r(35576),d=r(7526);let f=(e,t)=>t||("photo"===e?"jpg":"zip");var p=r(49737);r(97458);let g=(0,c.createContext)(null),m=()=>(0,c.useContext)(g)||{shouldTrackingLog:!0};var w=r(15715),v=r(32509),b=r(59916),y=r(72118),h=r(1850),k=r(64979),I=r(56879);let x=h.z.enum(["download","copy","edit","prompt","preview","remove_background","remove_background_edit","ai_video",k.cm,k.PF,k.p3,k.Kq,k.wK,k.os,k.H$,k.C0,k.u4,k.OI,k.Iu,k.e5,"ai_tool_retouch","ai_tool_retouch_after_download","ai_tool_expand","ai_tool_expand_after_download","ai_tool_reimagine","ai_tool_reimagine_after_download","ai_tool_adjust","ai_tool_adjust_after_download","ai_tool_replacebg","ai_tool_video","ai_tool_video_after_download","ai_tool_assistant","ai_tool_generate_prompt","ai_tool_generate_style_ref"]),N=h.z.enum(["workflow_create_post","workflow_create_poster","workflow_mix_images","workflow_apply_promo","workflow_create_flyer","workflow_create_logo_variations","workflow_localize","workflow_create_logo","workflow_apply_colors"]);h.z.object({resource:h.z.coerce.number(),file:I.ru.optional(),option:h.z.coerce.number().optional(),size:h.z.coerce.number().optional(),action:x.optional(),modifier:N.optional(),walletId:h.z.string().nullable().optional(),locale:h.z.string()}),h.z.object({data:h.z.object({filename:h.z.string(),url:h.z.string(),prompt:h.z.string().optional(),signed_url:h.z.string().optional()})}).transform(e=>{let{data:t}=e;return t}).transform(e=>{let{signed_url:t,...r}=e;return{...r,signedUrl:t}});let R=h.z.array(h.z.string()),z=new Date(new Date().getTime()+48e4),O=y.Z.withConverter({write:e=>e}),T=e=>{try{let t=O.get(e);if(!t)return[];return R.parse(JSON.parse(t))}catch(e){return[]}},C=()=>{let e=(0,i.I)(),t=(0,b.b)();return(0,c.useCallback)(r=>{if(!e)return;let o="".concat("ck_items_").concat(e),n=T(o),i="".concat(r);if(!n.includes(i)){let e=JSON.stringify([...n,i]);O.set(o,e,{path:"/",domain:t,expires:z})}},[e,t])},E=e=>{let{resource:t,file:r,action:g="download",modifier:b,location:y="resource_detail",option:h,size:k,showAttributionModal:I=!0,handleError:x,checkoutQueryParams:N,skipDownloadTracker:R=!1}=e,{id:z,name:O,author:T,premium:E,regularType:D,isAIGenerated:P,url:j}=t,[U,H]=(0,c.useState)(!1),{isUserWinback:S,showWinbackModal:W}=(0,a.l)(),{showAttribution:A}=(0,p.tc)(),L=C(),q=(0,v.b)({resource:t,location:y}),F=(0,_.mS)(),{shouldTrackingLog:K}=m(),{showDeviceBlockedModal:Z,isDeviceBlocked:$}=(0,n.qx)(),J=(0,o.Lh)(),Q=(0,i.I)(),B=(0,l.ZK)(),G=(0,s.TH)({file_extension:f(D,r),file_name:O,file_id:z,license:E?"premium":"free",resolution:k?d.w8[k]:"original",style:"na",author_name:T.name,category:P?"ai_image":D,action:"prompt"===g?"view_prompt":g,location:y,url_link:j}),M=(0,c.useCallback)(e=>{if(x){x(e);return}"prompt"!==g&&q(e,N)},[x,g,q,N]);return{handleDownload:(0,c.useCallback)(async(e,t)=>{if($){Z();return}if(S){W();return}H(!0),J||u.uT("WARNING: User ".concat(Q," has no wallet_id"),"warning"),K&&!R&&F({resourceId:z,isResourcePremium:E,resourceType:D,downloadType:g,fileType:D,variant:y});let o=await (0,w.H)({resource:z,size:k?2e3:void 0,action:g,modifier:b,file:r,option:h,walletId:J,locale:B});if(o.success)return I&&A&&A(),H(!1),L(z),G({externalUrl:null!=e?e:j,setting:t}),o.data;M(o),H(!1)},[$,S,J,K,R,z,k,g,b,r,h,B,M,Z,W,Q,F,E,D,y,I,A,L,G,j]),isDownloading:U}}},32509:function(e,t,r){r.d(t,{b:function(){return l}});var o=r(17842),n=r(10893),i=r(52983),a=r(65724);let l=e=>{var t;let{location:r,resource:l}=null!=e?e:{},{t:u}=(0,n.$G)("error"),{openToast:c}=(0,o.x_)(),s=(0,a.W)(null!==(t=null==l?void 0:l.id)&&void 0!==t?t:0,"",r);return(0,i.useCallback)((e,t)=>{if("DOWNLOAD_LIMIT_REACHED"===e.data&&l){s({resourceData:{name:l.name,mediaUrl:l.preview.url,mediaWidth:l.preview.width,mediaHeight:l.preview.height,resourceType:"regular"},checkoutQueryParams:t,modalType:"downloadLimit",origin:"download_limit"});return}if("AUTHENTICATION_ERROR"===e.data){window.location.href="/oauth-logout";return}"NOT_FOUND"===e.data&&c({type:"danger",message:u("notFound")}),"UNKNOWN_ERROR"===e.data&&c({type:"danger",message:u("unknown")})},[s,c,l,u])}},64237:function(e,t,r){r.d(t,{y:function(){return n}});var o=r(5704);let n=e=>{let{isEditableInMockup:t,isEditableInWepik:r}=e,n=(0,o.Jn)("type");return"illustration"===n?"illustration":t||"mockup"===n?"mockup":r||"template"===n?"template":void 0}}}]);